package com.ynny.demo06.service;

import com.ynny.demo06.dao.UserDao;
import com.ynny.demo06.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    @Autowired
    UserDao userDao;


    @Override
    public int register(User user) {

        //1.检查用户名是否存在
        User repeatUser = userDao.selectUserByUserName(user.getUsername());
        if (repeatUser != null){

            return 205;
        }
        //2.注册

        int i = userDao.insertUser(user);

        if (i != 1){
            return 502;
        }

        //3.注册成功 送积分

        return 200;
    }
}
